
function trim(str){
    return str.replace(/(^\s*)|(\s*$)/g,"");
  }//去掉空格
  
function search() {
document.indexForm.submit();
}


function isEmail(str){
	   var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
　　flag = pattern.test(str);  
       if(!flag) {
			alert("邮箱地址不合法!");
	   }
}


//================================================
function submitForm(){		 
		
		  var email = document.getElementById("email").value;
		  var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
		   if(!reg.test(email)) {
				alert("邮箱地址不合法!");
				return false;
		   }
		   
	  	document.addForm.submit(); 
}

function submitAddrs() {
		
		if(document.getElementById("consignee").value == "" ) {
			alert("请输入收货人姓名");
			return false;
		}	

	  //地区拼串
		var area_attr_str = "";
		if(document.getElementById("province").value!=""){
			area_attr_str += document.getElementById("province").value+"|";
			if(document.getElementById("eparchy_code").value!=""){
				area_attr_str += document.getElementById("eparchy_code").value+"|";
				if(document.getElementById("city_code").value!=""){
					area_attr_str += document.getElementById("city_code").value+"|";
				}
			}
		}

		if(area_attr_str == ""){
				alert("请选择地区！");
				return false; 
		}else{
			document.getElementById("area_attr").value = area_attr_str;
		}
		
		if(document.getElementById("address").value == "" ) {
			alert("请输入街道地址！");
			return false;
		}

		
		if(document.getElementById("tel").value=="") {
			if(document.getElementById("cellphone").value==""){
				alert("请输入固定电话或手机号码");
				return false;
			}
		}
	
		
		var cellphone = document.getElementById("cellphone");
		var myreg1=/^[1][\d]{10}$/;
		if(cellphone !=null && cellphone.value !="")
		{
			if(!myreg1.test(cellphone.value))
			{
			   alert("请输入有效的手机号码！");
			   return false;
			}
		}
		
		var phone = document.getElementById("tel");
		var myreg2 =/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
		if(phone !=null && phone.value !="")
		{
			if(!myreg2.test(phone.value))
			{
			   alert("请输入有效的电话号码！");
			   return false;
			}
		}
		
		document.addForm.submit(); 
}

function submitAddrs2() {
		
		if(document.getElementById("consignee").value == "" ) {
			alert("请输入收货人姓名");
			return false;
		}
		
		//地区拼串
		var area_attr_str = "";
		if(document.getElementById("province").value!=""){
			area_attr_str += document.getElementById("province").value+"|";
			if(document.getElementById("eparchy_code").value!=""){
				area_attr_str += document.getElementById("eparchy_code").value+"|";
				if(document.getElementById("city_code").value!=""){
					area_attr_str += document.getElementById("city_code").value+"|";
				}
			}
		}
		
		if(navigator.userAgent.indexOf("MSIE")>0) {
	
			if(document.getElementById("areaoutput").outerText == "" ) {
				if(area_attr_str == ""){
					alert("请选择地区！");
					return false;
				}
			}
		}
		
		if(navigator.userAgent.indexOf("Firefox")>0) {
			if(document.getElementById("areaoutput").textContent == "" ) {
				if(area_attr_str == ""){
					alert("请选择地区！");
					return false;
				}
			}
	　}

		if(area_attr_str != ""){
			document.getElementById("area_attr").value = area_attr_str;
		}
	
		if(document.getElementById("address").value == "" ) {
			alert("请输入街道地址！");
			return false;
		}

		
	if(document.getElementById("tel").value=="") {
			if(document.getElementById("cellphone").value==""){
				alert("请输入固定电话或手机号码");
				return false;
			}
		}
	
		
		var cellphone = document.getElementById("cellphone");
		var myreg1=/^[1][\d]{10}$/;
		if(cellphone !=null && cellphone.value !="")
		{
			if(!myreg1.test(cellphone.value))
			{
			   alert("请输入有效的手机号码！");
			   return false;
			}
		}
		
		var phone = document.getElementById("tel");
		var myreg2 =/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
		if(phone !=null && phone.value !="")
		{
			if(!myreg2.test(phone.value))
			{
			   alert("请输入有效的电话号码！");
			   return false;
			}
		}
		


		document.addForm.submit(); 
}


function ChangeOrg(){
	document.getElementById("org1").style.display = "none";
	document.getElementById("org2").style.display = "inline";
	document.getElementById("org_id").value = "";
}
